package exercise.database;

import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.youyunsoft.commons.BaseActivity;
import com.youyunsoft.commons.R;

import java.util.ArrayList;

public class DataBaseActivity extends BaseActivity {

    private MyDataBaseHelper dbHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_data_base);

        dbHelper = new MyDataBaseHelper(this, "BookStore.db", null, 1);

        Button createdDatabase = findViewById(R.id.create_database);
        createdDatabase.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dbHelper.getWritableDatabase();

            }
        });

        SQLiteDatabase sqLiteDatabase = dbHelper.getWritableDatabase();
        sqLiteDatabase.insert("", null, null);
        sqLiteDatabase.update("Book", new ContentValues(), "name=?", new String[]{"The Da Vinci Code"});
        sqLiteDatabase.delete("Book", "pages>?", new String[]{});


        ArrayList arrayList;
    }


    public static <T extends Comparable> T min(T[] a) {

        return null;
    }
}
